/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 晓星航
 * Date: 2023-12-10
 * Time: 16:02
 */
//递归
public class YanghuiTriangle3 {
    private static int getNumber(int row, int col) {
        if (col == 0 || col == row) {
            return 1;
        } else {
            return getNumber(row-1, col-1) + getNumber(row-1, col);
        }
    }

    public static void main(String[] args) {
        int numRows = 5; // 杨辉三角的行数

        for (int i = 0; i < numRows; i++) {
            for (int j = 0; j <= i; j++) {
                System.out.print(getNumber(i, j) + " ");
            }
            System.out.println();
        }
    }
}
